﻿CREATE TABLE [dbo].[UsersDevices] (
    [Id]       UNIQUEIDENTIFIER NOT NULL,
    [UserId]   UNIQUEIDENTIFIER NOT NULL,
    [Platform] INT              NOT NULL,
    [DeviceId] NVARCHAR (50)    NULL,
    [PushId]   NVARCHAR (255)   NULL,
    CONSTRAINT [PrimaryKey_48f431d5-3e26-4c41-9d86-2cd184f0e369] PRIMARY KEY CLUSTERED ([Id] ASC),
    CONSTRAINT [FK_UsersDevices_0] FOREIGN KEY ([UserId]) REFERENCES [dbo].[Users] ([Id]) ON DELETE CASCADE
);


GO
CREATE UNIQUE NONCLUSTERED INDEX [IX_User_Platform]
    ON [dbo].[UsersDevices]([UserId] ASC, [Platform] ASC);

